[filament_switch_sensor extruder_sensor]
pause_on_runout: False
runout_gcode:
    {% set printingstate = printer["gcode_macro START_PRINT"].printingstate|int %}
    {% if printer.idle_timeout.state | string == "Printing" and not printer.pause_resume.is_paused and printingstate %}
      #M118 State {printer.idle_timeout.state | string}
      #M118 Paused {printer.pause_resume.is_paused | string}
      {% set extruder_temp = printer.extruder.target %}
      PAUSE
      {% set extruder_num = printer.save_variables.variables.currentextruder|default(1)|int %}
      #SET_STEPPER_ENABLE STEPPER="extruder_stepper extr{extruder_num}" ENABLE=0
      
      {% set extruder_num = extruder_num + 1 %}
      {% if extruder_num > 2 %}
        {% set extruder_num = 1 %}
      {% endif %}
      #SYNCCURRENTEXTRUDER EXTRUDER_NUM={extruder_num}
      #SAVE_VARIABLE VARIABLE=currentextruder VALUE={extruder_num}
      _SET_ACTIVE_TOOL TOOL={extruder_num}
      {% if extruder_num == 1 %}
        MMU_MOTORS_OFF MOTOR=gear
      {% else %}
        MMU_MOTORS_OFF MOTOR=selector
      {% endif %}
      
      #LOAD_FILAMENT RESUMEAFTER=True FINALSTAGE=False
      #LOAD_FILAMENT DONTMOVETOTHENOZZLE=1 RESUMEAFTER=1
      LOAD_FILAMENT RESUMEAFTER=1 MOVECLEARAFTER=1 T={extruder_temp}
    {% endif %}
    
[save_variables]
filename: ~/printer_data/config/variables.cfg

#[duplicate_pin_override]
#pins: toolboard:PB4

[extruder]
max_extrude_only_distance: 3000
